//
//  NSString+Java.h
//
//  Created by GaoShin on 2019/8/29.
//

#import <Foundation/Foundation.h>

@interface NSString (Java)


/// Return the first index of the specified string.If not found,it will return -1.
/// @param str the string to be searched
-(NSInteger) indexOf:(NSString *) str;

/// Return the last index of the specified string.If not found,it will return -1.
/// @param str the string to be searched
-(NSInteger) lastIndexOf:(NSString *) str;


/// Return the first index of the specified char.If not found,it will return -1
/// @param cha the char to be searched
-(NSInteger) indexOfChar:(char) cha;

/// Return the last index of the specified char.If not found,it will return -1.
/// @param cha the char to be searched
-(NSInteger) lastIndexOfChar:(char) cha;


/// Similar as Java API substring(int start,int end)
/// @param from start index
/// @param to end index
-(NSString *) substringFromIndex:(NSUInteger)from To:(NSUInteger)to;


/// Similar as Java API startWith(String str)
/// @param prefix string to be searched
-(BOOL) startWith:(NSString *) prefix;


/// Similar as Java API endWith(String str)
/// @param suffix string to be searched
-(BOOL) endWith:(NSString *) suffix;


/// Similar as Java API split(String reg)
/// @param char1 split string
-(NSArray *) split:(NSString *) char1;


/// Similar as Java API trim()
-(NSString *) trim;


/// Similar as Java API valueOf(long i)
/// @param longlongValue value
+(NSString *) valueOf:(long long) longlongValue;


/// 字符串替换
/// @param oldStr 旧字符串
/// @param newString 新字符串
-(NSString *) replaceOldString:(NSString *) oldStr toNewString:(NSString *) newString;
@end

